<template>
  <div class="company-ranking">
    <h2 class="title">热门公司排行榜</h2>
    <div class="ranking-list">
      <div
        v-for="(company, index) in companies"
        :key="company.id"
        class="company-card"
      >
        <div class="company-info">
          <div class="rank">{{ index + 1 }}</div>
          <img
            :src="company.avatar"
            :alt="company.name + ' logo'"
            class="company-avatar"
          />
          <div class="company-details">
            <h3 class="company-name">{{ company.name }}</h3>
            <p class="company-size">{{ company.size }}</p>
            <p class="company-industry">{{ company.industry }}</p>
            <p class="company-listing" :class="{ listed: company.isListed }">
              {{ company.isListed ? '已上市' : '未上市' }}
            </p>
          </div>
        </div>
        <div class="job-listings">
          <h4>热门职位</h4>
          <ul>
            <li
              v-for="job in company.jobs.slice(0, 2)"
              :key="job.id"
              class="job-item"
            >
              <h5 class="job-title">{{ job.title }}</h5>
              <p class="job-salary">{{ job.salary }}</p>
              <p class="job-location">{{ job.location }}</p>
              <div class="job-tags">
                <span v-for="tag in job.tags" :key="tag" class="job-tag">{{
                  tag
                }}</span>
              </div>
              <p class="job-requirements">
                {{ job.experience }} | {{ job.education }}
              </p>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'

const companies = ref([
  {
    id: 1,
    name: '腾讯科技',
    size: '10000人以上',
    industry: '互联网',
    avatar: '/placeholder.svg?height=120&width=120',
    isListed: true,
    jobs: [
      {
        id: 1,
        title: '高级前端工程师',
        salary: '30k-50k',
        location: '深圳',
        tags: ['前端', 'Vue', 'React'],
        experience: '3-5年经验',
        education: '本科及以上'
      },
      {
        id: 2,
        title: '产品经理',
        salary: '25k-40k',
        location: '北京',
        tags: ['产品', '用户增长'],
        experience: '5-7年经验',
        education: '本科及以上'
      },
      {
        id: 3,
        title: '数据分析师',
        salary: '20k-35k',
        location: '广州',
        tags: ['数据分析', 'SQL', 'Python'],
        experience: '1-3年经验',
        education: '硕士及以上'
      }
    ]
  },
  {
    id: 2,
    name: '阿里巴巴',
    size: '10000人以上',
    industry: '电子商务',
    avatar: '/placeholder.svg?height=120&width=120',
    isListed: true,
    jobs: [
      {
        id: 4,
        title: 'Java开发工程师',
        salary: '25k-50k',
        location: '杭州',
        tags: ['Java', 'Spring Boot', 'MySQL'],
        experience: '3-5年经验',
        education: '本科及以上'
      },
      {
        id: 5,
        title: 'UI设计师',
        salary: '15k-30k',
        location: '上海',
        tags: ['UI', 'Sketch', 'Figma'],
        experience: '1-3年经验',
        education: '本科及以上'
      },
      {
        id: 6,
        title: '算法工程师',
        salary: '30k-60k',
        location: '杭州',
        tags: ['机器学习', 'Python', 'TensorFlow'],
        experience: '3-5年经验',
        education: '硕士及以上'
      }
    ]
  },
  {
    id: 3,
    name: '字节跳动',
    size: '10000人以上',
    industry: '互联网',
    avatar: '/placeholder.svg?height=120&width=120',
    isListed: false,
    jobs: [
      {
        id: 7,
        title: '后端开发工程师',
        salary: '30k-60k',
        location: '北京',
        tags: ['Go', 'microservices', 'Docker'],
        experience: '3-5年经验',
        education: '本科及以上'
      },
      {
        id: 8,
        title: '产品运营',
        salary: '15k-30k',
        location: '上海',
        tags: ['运营', '用户增长', '数据分析'],
        experience: '1-3年经验',
        education: '本科及以上'
      },
      {
        id: 9,
        title: '机器学习工程师',
        salary: '35k-70k',
        location: '深圳',
        tags: ['机器学习', 'Python', 'PyTorch'],
        experience: '3-5年经验',
        education: '硕士及以上'
      }
    ]
  },
  {
    id: 4,
    name: '华为技术',
    size: '10000人以上',
    industry: '通信/硬件',
    avatar: '/placeholder.svg?height=120&width=120',
    isListed: false,
    jobs: [
      {
        id: 10,
        title: '5G网络工程师',
        salary: '25k-45k',
        location: '深圳',
        tags: ['5G', '网络优化', 'LTE'],
        experience: '3-5年经验',
        education: '本科及以上'
      },
      {
        id: 11,
        title: '硬件开发工程师',
        salary: '20k-40k',
        location: '东莞',
        tags: ['硬件设计', 'PCB', '嵌入式系统'],
        experience: '3-5年经验',
        education: '本科及以上'
      },
      {
        id: 12,
        title: '软件测试工程师',
        salary: '15k-30k',
        location: '西安',
        tags: ['自动化测试', 'Python', 'Selenium'],
        experience: '1-3年经验',
        education: '本科及以上'
      }
    ]
  }
])
</script>

<style scoped>
.company-ranking {
  font-family: Arial, sans-serif;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.title {
  font-size: 28px;
  font-weight: bold;
  margin-bottom: 30px;
  color: #333;
  text-align: center;
}

.ranking-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 30px;
}

.company-card {
  display: flex;
  background-color: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: transform 0.3s ease;
}

.company-card:hover {
  transform: translateY(-5px);
}

.company-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background-color: #f8f9fa;
  width: 40%;
}

.rank {
  font-size: 32px;
  font-weight: bold;
  color: #ff6b6b;
  margin-bottom: 15px;
}

.company-avatar {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  margin-bottom: 15px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.company-details {
  text-align: center;
}

.company-name {
  font-size: 20px;
  font-weight: bold;
  margin: 0 0 10px;
  color: #333;
}

.company-size,
.company-industry,
.company-listing {
  font-size: 14px;
  color: #666;
  margin: 0 0 5px;
}

.company-listing {
  font-weight: bold;
  margin-top: 5px;
}

.company-listing.listed {
  color: #4caf50;
}

.job-listings {
  padding: 20px;
  width: 60%;
}

.job-listings h4 {
  font-size: 18px;
  margin: 0 0 15px;
  color: #333;
  border-bottom: 2px solid #eee;
  padding-bottom: 10px;
}

.job-item {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid #eee;
}

.job-item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.job-title {
  font-size: 16px;
  font-weight: bold;
  margin: 0 0 5px;
  color: #4a90e2;
}

.job-salary,
.job-location,
.job-requirements {
  font-size: 14px;
  color: #666;
  margin: 0 0 5px;
}

.job-tags {
  margin: 5px 0;
}

.job-tag {
  display: inline-block;
  background-color: #e0f2f1;
  color: #00897b;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 12px;
  margin-right: 5px;
  margin-bottom: 5px;
}

@media (max-width: 1200px) {
  .ranking-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .company-card {
    flex-direction: column;
  }

  .company-info,
  .job-listings {
    width: 100%;
  }

  .company-avatar {
    width: 100px;
    height: 100px;
  }

  .rank {
    font-size: 28px;
  }

  .company-name {
    font-size: 18px;
  }
}
</style>
